package com.xbongbong.paas.toolbox.helper;/*/*/

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 评论内容 过滤用help
 * @author 魏荣杰
 * @date 2019/5/11 19:30
 * @since v1.0
 * @version v1.0
 */
public class CommentHelp {

    /**
     * Description: 过滤 有@标签的文本 如:<span class=\"at-person\">xxxx&nbsp;</span>xxx
     * @param content 需要过滤的文本
     * @return java.lang.String
     * @author 魏荣杰
     * @date 2019/5/11 21:05
     * @since v1.0
     */
    public static String filterCommentContent(String content) {
        //先过滤空格
        String regExBlank = "&nbsp;";
        Pattern patternBlank = Pattern.compile(regExBlank, Pattern.CASE_INSENSITIVE);
        Matcher matcherBlank = patternBlank.matcher(content);
        content = matcherBlank.replaceAll(" ");
        //过滤html
        String regEx = "(</?.*?>)";
        Pattern pattern = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(content);
        content = matcher.replaceAll("");
        return content;
    }

}
